package com.wjt.homestayms.config;

import com.wjt.homestayms.interceptor.LoginInterceptor;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class WebConfig implements WebMvcConfigurer  {
    @Override
    public void addInterceptors(InterceptorRegistry registry) {
        registry.addInterceptor(new LoginInterceptor())
                .addPathPatterns("/templates/*")  //拦截templates目录下的所有请求。
                .excludePathPatterns("/css/**","/images/**","/js/**", "/fonts/**","/","/login","/vue/**", "/public/lib/**"
                );  //除这些配置的请求会被放行。其他请求都会被拦截。

    }

}
